//
//  SJBuyView.m
//  YYPHSpeedJump
//
//  Created by sujiang on 16/3/10.
//  Copyright © 2016年 sujiang. All rights reserved.
//

#define kNumViewWidth(A,B) ([UIScreen mainScreen].bounds.size.width > 370?A:B)

#import "SJBuyView.h"

@implementation SJBuyView

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self == [super initWithFrame:frame]) {
        [self addSubViews];
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)addSubViews
{
    UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0, 10, kScreenWidth, 40)];
    [self addSubview:topView];
    self.numView = [[NumberJumpView alloc] initWithFrame:CGRectMake((topView.width - kNumViewWidth(160, 140)) / 2, 0, kNumViewWidth(160, 140), topView.height) numberCount:5];
    [topView addSubview:self.numView];
    UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake((self.numView.left - 64) / 2, 0, 64, topView.height)];
    [topView addSubview:lable];
    lable.textAlignment = NSTextAlignmentCenter;
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"速降中:"];
    [str addAttribute:NSForegroundColorAttributeName value:kColors(210, 2, 2, 1) range:NSMakeRange(0,2)];
    [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:20] range:NSMakeRange(0, 2)];
    lable.attributedText = str;
    self.numView.fontNum = 24;
    
    
    self.nameLb = [[UILabel alloc] initWithFrame:CGRectMake(20, topView.bottom + 10, kScreenWidth - 40, 15)];
    [self addSubview:self.nameLb];
    self.nameLb.font = [UIFont systemFontOfSize:15];
    self.nameLb.textAlignment = NSTextAlignmentCenter;
    self.imageView = [[UIImageView alloc] initWithFrame:CGRectMake((kScreenWidth - 185 * kWidthScale) / 2, self.nameLb.bottom + 10, 185 * kWidthScale, 185 * kWidthScale)];
    [self addSubview:self.imageView];
    self.imageView.image = [UIImage imageNamed:@"tu-zhong02"];
    self.imageView.userInteractionEnabled = YES;
    UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(self.imageView.right + 10, self.imageView.center.y - 30, 64 * kWidthScale, 60 * kWidthScale)];
    [self addSubview:imageV];
    imageV.image = [UIImage imageNamed:@"fire"];
    self.userCount = [[UILabel alloc] initWithFrame:CGRectMake(imageV.left, imageV.bottom + 5, imageV.width, 14)];
    self.userCount.font = [UIFont systemFontOfSize:14];
    self.userCount.textColor = kColors(220, 2, 2, 1);
    self.userCount.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.userCount];
    self.userCount.text = @"0人";
    
    self.clickBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    self.clickBtn.frame = CGRectMake(0, self.imageView.bottom + 5, kScreenWidth, 35);
    [self addSubview:self.clickBtn];
    self.clickBtn.backgroundColor = kColors(159, 159, 159, 1);
    [self.clickBtn setTitle:@"点击查看图文详情" forState:(UIControlStateNormal)];
    [self.clickBtn setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
    self.clickBtn.titleLabel.font = [UIFont systemFontOfSize:14.0f];
    
    UILabel *lable1 = [[UILabel alloc] initWithFrame:CGRectMake((kScreenWidth - 65) / 2, self.clickBtn.bottom + 4, 65, 13)];
    [self addSubview:lable1];
    lable1.textAlignment = NSTextAlignmentCenter;
    lable1.textColor = kColors(102, 102, 102, 1);
    lable1.text = @"出价排行榜";
    lable1.font = [UIFont systemFontOfSize:13];
    
    UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, kScreenHeight - 66 - 70 * kWidthScale, kScreenWidth, 70 * kWidthScale)];
    [self addSubview:bottomView];
    
    self.buyBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
    self.buyBtn.frame = CGRectMake((bottomView.width - 67 * kWidthScale) / 2, 0, 67 * kWidthScale, bottomView.height);
    [bottomView addSubview:self.buyBtn];
    [self.buyBtn setBackgroundImage:[UIImage imageNamed:@"buyBtn"] forState:(UIControlStateNormal)];
//    self.coolCount = [[UILabel alloc] initWithFrame:CGRectMake(self.buyBtn.left - 80, (bottomView.height - 53 ) / 2, 50, 14)];
//    [bottomView addSubview:self.coolCount];
//    self.coolCount.font = [UIFont systemFontOfSize:14];
//    self.coolCount.textColor = kColors(218, 166, 46, 1);
//    self.coolCount.text = @"1000人";
//    self.coolBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
//    self.coolBtn.frame = CGRectMake(self.coolCount.left + 8, self.coolCount.bottom + 5, 34, 34);
//    [bottomView addSubview:self.coolBtn];
//    [self.coolBtn setTitle:@"赞" forState:(UIControlStateNormal)];
//    self.coolBtn.layer.cornerRadius = self.coolBtn.width / 2;
//    [self.coolBtn setTitleColor:kColors(218, 166, 46, 1) forState:(UIControlStateNormal)];
//    self.coolBtn.layer.borderWidth = 2.0f;
//    self.coolBtn.layer.borderColor = kColors(218, 166, 46, 1).CGColor;
//    self.coolBtn.layer.masksToBounds = YES;
    
//    self.waitCount = [[UILabel alloc] initWithFrame:CGRectMake(self.buyBtn.right + 30, (bottomView.height - 53 ) / 2, 50, 14)];
//    [bottomView addSubview:self.waitCount];
//    self.waitCount.font = [UIFont systemFontOfSize:14];
//    self.waitCount.textColor = kColors(218, 166, 46, 1);
//    self.waitCount.text = @"1000人";
//    self.waitBtn = [UIButton buttonWithType:(UIButtonTypeCustom)];
//    self.waitBtn.frame = CGRectMake(self.waitCount.left + 8, self.waitCount.bottom + 5, 34, 34);
//    [bottomView addSubview:self.waitBtn];
//    [self.waitBtn setTitle:@"等" forState:(UIControlStateNormal)];
//    self.waitBtn.layer.cornerRadius = self.waitBtn.width / 2;
//    [self.waitBtn setTitleColor:kColors(218, 166, 46, 1) forState:(UIControlStateNormal)];
//    self.waitBtn.layer.borderWidth = 2.0f;
//    self.waitBtn.layer.borderColor = kColors(218, 166, 46, 1).CGColor;
//    self.waitBtn.layer.masksToBounds = YES;
    
    self.leftPriceList = [[UIView alloc] initWithFrame:CGRectMake(0, lable1.bottom + 4, kScreenWidth / 2, bottomView.top - lable1.bottom - 4)];
    [self addSubview:self.leftPriceList];
    
    self.rightPriceList = [[UIView alloc] initWithFrame:CGRectMake(self.leftPriceList.right, self.leftPriceList.top, kScreenWidth / 2, self.leftPriceList.height)];
    [self addSubview:self.rightPriceList];
    UILabel *la = [[UILabel alloc] initWithFrame:CGRectMake((self.leftPriceList.width - 50) / 2, 5, 50, 12)];
    [self.leftPriceList addSubview:la];
    la.textAlignment = NSTextAlignmentCenter;
    la.textColor = kColors(218, 166, 46, 1);
    la.font = [UIFont systemFontOfSize:12];
    la.text = @"出价序列";
    
    UILabel *lar = [[UILabel alloc] initWithFrame:CGRectMake((self.leftPriceList.width - 50) / 2, 5, 50, 12)];
    [self.rightPriceList addSubview:lar];
    lar.textAlignment = NSTextAlignmentCenter;
    lar.textColor = kColors(218, 166, 46, 1);
    lar.font = [UIFont systemFontOfSize:12];
    lar.text = @"出价序列";
    
    self.bgView = [[UIView alloc] initWithFrame:CGRectMake(0, self.leftPriceList.top, kScreenWidth, self.leftPriceList.height)];
    self.bgView.backgroundColor = kColors(51, 51, 51, 1);
    self.bgView.alpha = 0.71;
    [self addSubview:self.bgView];
    
    self.lable0 = [[UILabel alloc] initWithFrame:CGRectMake((self.bgView.width - 230) / 2, (self.bgView.height - 36) / 2, 85, 36)];
    [self.bgView addSubview:self.lable0];
    self.lable0.textAlignment = NSTextAlignmentCenter;
    self.lable0.font = [UIFont systemFontOfSize:36];
    self.lable0.textColor = kColors(255, 255, 255, 1);
    self.lable0.text = @"原价:";
    self.orginalPrice = [[UILabel alloc] initWithFrame:CGRectMake(self.lable0.right+1, self.lable0.top, 145, 36)];
    self.orginalPrice.font = [UIFont systemFontOfSize:36];
    self.orginalPrice.textColor = kColors(255, 255, 255, 1);
    self.orginalPrice.textAlignment = NSTextAlignmentCenter;
    [self.bgView addSubview:self.orginalPrice];

}


@end
